import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALGWRGJe0z/0IZOXhqhXVylYl1VChYkB\n" +
  "vbmiMZBNvSFTS94eY0uiUXhMdcrkr592p5mfIV2kUqaVvMennqLXSdkCAwEAAQ==";

const privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAsZZEYl7TP/Qhk5eG\n" +
  "qFdXKViXVUKFiQG9uaIxkE29IVNL3h5jS6JReEx1yuSvn3anmZ8hXaRSppW8x6ee\n" +
  "otdJ2QIDAQABAkBP66Z+9tnvcDkkKQ9K93OcgegpULS0AfqWbm4L2VCCjDAuBn20\n" +
  "CrGNjW4kpaZPIBGEPjabLdV3kO+T0E8/gBHhAiEA10lkLZp7Q8y2kjqGmGAsJE6V\n" +
  "/JJj3LrCoOUKtC8PPa0CIQDTK7tFYV1xsX8drsh6iWDDGpIId/UQGIWSVvUBgd2q\n" +
  "XQIhAKVl3y8iFj2ak1F44VtD1+X08kpfdZVpbooKLdUMqprpAiBNOBeh9kmyUoK2\n" +
  "OvzKekPs9GFkQWFWwnDNo4iyRWfmbQIgd4SzgkJRRyapzBQkgNGmUMNcjuF7kmB+\n" +
  "q8q/qmYVJvM=";

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密 todo lxw 解密失败返回 false
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

